package com.lebang.controller.api.member;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.lebang.aop.Sessionid;
import com.lebang.common.MemberLock;
import com.lebang.common.Require;
import com.lebang.common.Util;
import com.lebang.common.util.QRCodeUtil;
import com.lebang.common.util.RequestUtil;
import com.lebang.common.validcode.IdCardStatus;
import com.lebang.common.validcode.RedisLogin;
import com.lebang.common.validcode.ValidCodeStatus;
import com.lebang.common.validcode.ValidCodeUtil;
import com.lebang.component.RedisClient;
import com.lebang.component.UMengPushComponent;
import com.lebang.domain.MemberCashWithdrawal;
import com.lebang.domain.MemberIdentityInfo;
import com.lebang.domain.MemberWallet;
import com.lebang.entity.RequestHeaders;
import com.lebang.entity.TaskRewards;
import com.lebang.entity.TaskRewardsRecord;
import com.lebang.entity.member.*;
import com.lebang.example.LbbMemberTradeExample;
import com.lebang.feign.AppDictFeign;
import com.lebang.mapper.setting.CashMapper;
import com.lebang.model.NmgToken;
import com.lebang.model.RequestUserInfo;
import com.lebang.model.ValidCodeRecord;
import com.lebang.model.back.Result;
import com.lebang.model.enums.Booleans;
import com.lebang.model.enums.CheckStatus;
import com.lebang.model.enums.Gender;
import com.lebang.model.enums.buss.RewardType;
import com.lebang.model.enums.buss.TaskStatus;
import com.lebang.model.enums.buss.TradeCategory;
import com.lebang.model.enums.buss.TradeStatus;
import com.lebang.model.setting.Cash;
import com.lebang.service.*;
import com.lebang.service.buss.*;
import com.lebang.service.mongodb.QuBaoTokenMongodb;
import com.lebang.service.sys.AppLookCategoryService;
import com.lebang.service.sys.MemberCashWithdrawalService;
import com.lebang.service.sys.RegisterWhiteImeiService;
import com.lebangweb.common.DateUtil;
import com.lebangweb.common.TextUtil;
import com.lebangweb.common.UUIDUtil;
import com.lebangweb.encrypt.MessageDigestUtil;
import com.lebangweb.response.Callback;
import com.lebangweb.response.JsonData;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

import static com.lebang.common.validcode.RedisLock.LOCKPHONECODE;
import static com.lebang.common.validcode.ValidCodeUtil.ID_CARD_COUNT;
import static com.lebang.controller.sys.MemberCashWithdrawalController.ALI_CASH_RECORD;

/**
 * 用户管理
 *
 * @author weizx
 * @className MemberApi
 * @date 2018年7月24日 下午2:05:10
 */
@RestController
public class MemberApi {
    @Autowired
    private MemberNewTaskService newTaskService;
    public static final String CASH = "lock:cash:";



    @Autowired
    private WalletService walletService;

    @Autowired
    private MemberService memberService;

    @Autowired
    private MemberFeedbackService memberFeedbackService;


    @Autowired
    private MemberTradeService memberTradeService;

    @Autowired
    private MemberInviteDetailService memberInviteDetailService;

    @Autowired
    private CashMapper cashMapper;

    @Autowired
    private MemberRecordService memberRecordService;
    @Autowired
    private RedisClient redisClient;
    @Autowired
    private ValidCodeUtil validCodeUtil;
    @Autowired
    private AppDictFeign appDictFeign;

    //2020-06-10 11:21:11
    public static final Date MEMBER_DATE = new Date(1591759271000L);
    //2020-06-10 11:21:11
    public static final Date C_MEMBER_DATE = new Date(1591759271000L);
    @Autowired
    private FastLoginService fastLoginService;
    @Autowired
    private UMengPushComponent uMengPushComponent;
    @Autowired
    private QuBaoTokenMongodb quBaoTokenMongodb;
    @Autowired
    private MemberWalletService memberWalletService;
    @Autowired
    private MemberCashWithdrawalService memberCashWithdrawalService;
    @Autowired
    private MemberIdentityInfoService memberIdentityInfoService;
    @Autowired
    private AppLookCategoryService appLookCategoryService;
    @Autowired
    private RankingService rankingService;
    @Autowired
    private MemberNoticeService memberNoticeService;
    @Autowired
    private RegisterWhiteImeiService registerWhiteImeiService;


    /**
     * 用户注册
     *
     * @param request
     * @return
     * @author weizx
     * @date 2018年7月24日 下午2:07:19
     */
    @RequestMapping(value = "/member/register", method = {RequestMethod.GET, RequestMethod.POST})
    public JsonData register(@RequestParam(value = "phone") String phone,
                             @RequestParam(value = "password") String password,
                             @RequestParam(value = "code") String code,
                             @RequestParam(value = "inviteCode", required = false) String inviteCode, HttpServletRequest request,String city) {
        try {
            //提取头部数据
            RequestHeaders requsetHeader = RequestUtil.getHeader(request);
            // 校验验证码
//            if (!validCodeUtil.checkCode(phone, RedisLogin.PHONE_REGISTER_CODE, code)) {
//                return Callback.fail("invalid_code", "验证码错误！");
//            }
            if (memberService.checkImei(requsetHeader.getImei())) {
                return Callback.fail("invalid_code", "一个设备号最多注册1个账号,有疑问请联系客服");
            }
            // 判断手机号是否注册过
            LbbMember memberr = new LbbMember();
            memberr.setPhone(phone);
            memberr.setAppId(requsetHeader.getAppid());
            LbbMember member = memberService.getMember(memberr);
            if (member != null) {
                return Callback.fail("exist", "手机号已被注册！");
            }
            //生成邀请码
            String icode = memberService.inviteCode();
            String inviterId = "";
            if (null != inviteCode && !"".equals(inviteCode)) {
                LbbMember member3 = memberService.getByinviteCode(inviteCode);
                if (member3 != null) {
                    inviterId = member3.getMemberId();
                }
            }
            member = new LbbMember();
            member.setRequestUri(request.getRequestURI());
            member.setBrand(requsetHeader.getBrand());
            member.setImei(requsetHeader.getImei());
            member.setAppStore(requsetHeader.getAppStore());
            member.setAlipay("");
            member.setAlipayName("");
            member.setAppId(requsetHeader.getAppid());
            member.setAvatar("");
            member.setBirthday("");
            member.setCategory("True");
            member.setGender(Gender.Unknow.name());
            member.setInviteCode(icode);
            member.setInviterId(inviterId);
            member.setMemberId(UUIDUtil.L());
            member.setNickname(phone);
            member.setPassword(MessageDigestUtil.encryptMD5(password.getBytes()));
            member.setPersonId("");
            member.setPhone(phone);
            member.setRealname("");
            member.setStatus("");
            member.setUnionid("");
            member.setWeixin("");
            member.setWeixinName("");
            member.setCity(city);
            memberService.insertMember(member);
            member = memberService.getMemberByMemberId(member.getMemberId());
            Map<String, Object> m = getLoginData(member);

            //验证成功删除验证码
            validCodeUtil.cleanCode(phone, RedisLogin.PHONE_REGISTER_CODE, code);
            memberWalletService.initData(member.getMemberId());
            return Callback.success("success", "注册成功!", m);
        } catch (Exception e) {
            e.printStackTrace();
            return Callback.fail("error", e.getMessage());
        }
    }


    /**
     * 构建分享的map
     *
     * @param iviteCode
     * @return
     */
    public Map<String, Object> getRecommend(String iviteCode) {
        Map<String, Object> recommend = new HashMap<String, Object>(1);
        recommend.put("icon", "http://p5vcsyy4d.bkt.clouddn.com/fish_icon.png");
        recommend.put("title", "小哥哥、小姐姐零花钱了解下~");
        recommend.put("href", "http://newapi.hotbuybuy.com/invite/check?inviteCode=" + iviteCode);
        return recommend;
    }


    /**
     * 获取登录后的用户信息
     *
     * @param member
     * @return
     */
    public Map<String, Object> getLoginData(LbbMember member) {
        if (member != null) {
            Map<String, Object> mapt = (Map<String, Object>) JSONObject.toJSON(member);
//            Map<String, Object> map = JSONObject.fromObject(member);
            Map<String, Object> recommend = getRecommend(member.getInviteCode());
            mapt.put("time", DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm"));
//            map.put("time", new Date().stringify("yyyy-MM-dd HH:mm"));
            mapt.put("recommend", recommend);
            return mapt;
        }
        return null;
    }


    /**
     * 登录
     *
     * @param phone
     * @param password
     * @param request
     * @param response
     * @return
     * @author weizx
     * @date 2018年7月24日 下午7:40:40
     */
    @Sessionid
    @RequestMapping(value = "/member/login", method = {RequestMethod.GET, RequestMethod.POST})
    public JsonData login(@RequestParam(value = "phone") String phone,
                          @RequestParam(value = "password") String password, HttpServletRequest request,
                          HttpServletResponse response) {
        RequestHeaders requestHeaders = new RequestHeaders(request);
        try {
            String appid = requestHeaders.getAppid();
            LbbMember lbbMember = new LbbMember();
            lbbMember.setAppId(appid);
            lbbMember.setPhone(phone);
            lbbMember.setPassword(MessageDigestUtil.encryptMD5(password.getBytes()));
            LbbMember member = memberService.getMember(lbbMember);
            if (member == null) {
                return Callback.fail("fail", "账号或密码错误！", new HashMap<>());
            }
            checkMember(member);
            Map<String, Object> m = getLoginData(member);
            fastLoginService.insertRecord(member.getMemberId(), 1);
            return Callback.success("success", "登录成功!", m);
        } catch (Exception e) {
            e.printStackTrace();
            return Callback.fail("error", e.getMessage());
        }
    }


    /**
     * 14 天 超时绑定检测
     *
     * @param member
     * @return
     */
    public boolean checkMember(LbbMember member) {
        try {
            //如果用户含有推荐人信息，查看用户拉新记录表中有无记录，如无记录，侧需要检测用户注册时间是否超过14天，超过则解除绑定
            if (!TextUtil.isEmpty(member.getInviterId())) {
                LbbMemberInviteDetail memberInviteDetail = memberInviteDetailService.getByInviteAndMemberId(
                        member.getMemberId(), member.getInviterId());
                if (memberInviteDetail == null) {
                    long registerTime = member.getCreateTime().getTime();
                    long nowTime = System.currentTimeMillis();
                    long times = nowTime - registerTime - 14 * 86400000;
                    if (times > 0) {
                        member.setInviterId("");
                        memberService.updateMemberById(member);
                    }
                }
            }
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }


    /**
     * 发送验证码(注册)
     *
     * @param phone
     * @param request
     * @param response
     * @return
     * @author weizx
     * @date 2018年7月24日 下午2:48:42
     */
    @Sessionid
    @RequestMapping(value = "/member/valid/register", method = {RequestMethod.GET, RequestMethod.POST})
    public JsonData validRegister(@RequestParam(value = "phone") String phone, HttpServletRequest request,
                                  HttpServletResponse response, HttpSession session) {
        try {
            // 验证手机格式
            if (!TextUtil.isMobile(phone)) {
                return Callback.fail("invalid_phone", "请输入正确的手机号！");
            }
            // 判断手机号是否注册过
            LbbMember lbbMember = new LbbMember();
            lbbMember.setAppId("xianyu");
            lbbMember.setPhone(phone);
            LbbMember member = memberService.getMember(lbbMember);
            if (member != null) {
                return Callback.fail("exist", "手机号已被注册！");
            }
            //加锁防止重复发
            String uuid = UUIDUtil.M();
            boolean a = redisClient.tryGetDistributedLock(LOCKPHONECODE.getName() + phone, uuid, 3000);
            if (a) {

                ValidCodeStatus validCode = validCodeUtil.getValidCode(phone, new ValidCodeRecord(request));
                if (validCode.isStatus()) {
                    //验证码存入redis中
                    redisClient.setex(RedisLogin.PHONE_REGISTER_CODE.getName() + phone, 300, validCode.getCode());

                    return Callback.success("success", "发送成功", "");
                } else {
                    return Callback.fail("fail", "发送失败" + validCode.getMsg(), null);
                }
            } else {
                return Callback.fail("fail", "请勿重复操作哦", null);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return Callback.fail("error", e.getMessage());
        }
    }


    /**
     * 用户二维码
     *
     * @param request
     * @param response
     * @param session
     * @author weizx
     * @date 2018年7月25日 下午2:47:56
     */
    @RequestMapping(value = "/member/qrocde/{userid}", method = {RequestMethod.GET, RequestMethod.POST})
    public void QRCode(@PathVariable(value = "userid") String userid, HttpServletRequest request,
                       HttpServletResponse response, HttpSession session) {
        try {
            LbbMember member = memberService.getMemberByMemberId(userid);
            if (member == null) {
                return;
            }
            QRCodeUtil.createImage(("http://newapi.hotbuybuy.com/invite/" + member.getInviteCode()), "png", response.getOutputStream());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 支付宝信息修改
     *
     * @param request
     * @param response
     * @param session
     * @return
     * @author weizx
     * @date 2018年7月25日 下午2:57:41
     */
    @Require
    @Sessionid
    @RequestMapping(value = "/member/setting/alipay", method = {RequestMethod.GET, RequestMethod.POST})
    public JsonData alipay(@RequestParam(value = "name") String name, @RequestParam(value = "alipay") String alipay,
                           HttpServletRequest request, HttpServletResponse response, HttpSession session) {
        RequestHeaders requestHeaders = new RequestHeaders(request);
        try {
            String userid = requestHeaders.getUserid();
            try {
                if (memberCashWithdrawalService.allow(userid)) {
                    return Callback.fail("invalid", "提现审批中无法修改");
                }
                if (redisClient.exists(ALI_CASH_RECORD + ":" + userid)) {
                    return Callback.fail("invalid", "提现成功14天内无法修改信息");
                }
                if (TextUtil.isEmpty(alipay, name)) {
                    return Callback.fail("invalid", "账号不能为空");
                }
                LbbMember member = memberService.getMemberByMemberId(userid);
                if (member == null) {
                    return Callback.fail("invalid", "账号不存在！");
                } else {
                    //库表存在支付宝号
                    boolean count = memberService.selectByAilPay(alipay, name);
                    //输入的支付宝号与绑定的支付宝号相同
                    boolean isEqual = !TextUtil.isEmpty(member.getAlipay())&&member.getAlipay().equals(alipay);
                    if(!isEqual&&count){
                        return Callback.fail("invalid", "一个支付宝账号最多绑定1个账号,有疑问请联系客服！");
                    }
                    if (!member.getAlipayName().equals(name)) {
                        member.setZfbIcard("");
                    }
                    member.setAlipay(alipay);
                    member.setAlipayName(name);
                    memberService.updateMemberById(member);
                    return Callback.success("success", "设置成功!");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            return Callback.fail("fail", "设置失败，请稍后再试！");
        } catch (Exception e) {
            e.printStackTrace();
            return Callback.fail("error", e.getMessage());
        }
    }


    /**
     * 用户钱包（今日收入、账户余额、已提现金额）
     *
     * @param request
     * @param response
     * @param session
     * @return
     * @author weizx
     * @date 2018年7月25日 下午6:31:16
     */
    @Sessionid
    @Require
    @RequestMapping(value = "/member/wallet", method = {RequestMethod.GET, RequestMethod.POST})
    @MemberLock
    public JsonData wallet(HttpServletRequest request, HttpServletResponse response, HttpSession session) {
        RequestHeaders requestHeaders = new RequestHeaders(request);
        try {
            // 校验应用
            String userid = requestHeaders.getUserid();
            JSONObject jsonObject = new JSONObject();
            MemberWallet memberWallet=memberWalletService.selectWallet(userid);
            jsonObject.put("balance", new BigDecimal(memberWallet.getMoney()).divide(new BigDecimal(100)).setScale(2).toString());
            jsonObject.put("all", memberWallet.getAllMoney());
            if (jsonObject.getBigDecimal("balance").compareTo(BigDecimal.ZERO) < 0) {
              //  memberTradeService.walletClean(userid);
                jsonObject.put("balance", new BigDecimal(memberWalletService.getMoneyByMemberId(userid)).divide(new BigDecimal(100)).setScale(2).toString());
                jsonObject.put("all", memberWalletService.getAllMoneyByMemberId(userid));
            }
            return Callback.success("success", "已返回用户钱包信息!", jsonObject);

        } catch (Exception e) {
            e.printStackTrace();
            return Callback.fail("error", e.getMessage());
        }
    }

    /**
     * 收入/支出明细
     *
     * @param request
     * @param response
     * @param session
     * @return
     * @author weizx
     * @date 2018年7月25日 下午8:20:27
     */
    @Require
    @Sessionid
    @RequestMapping(value = "/member/wallet/{category}", method = {RequestMethod.GET, RequestMethod.POST})
    public JsonData wallets(@RequestParam(value = "page", required = false) Integer page,
                            @RequestParam(value = "size", required = false) Integer size,
                            @PathVariable(value = "category") String category, HttpServletRequest request, HttpServletResponse response,
                            HttpSession session) {
        RequestHeaders requestHeaders = new RequestHeaders(request);
        try {
            // 校验应用
            String appid = requestHeaders.getAppid();
            String userid = requestHeaders.getUserid();
            try {
                LbbMemberTradeExample example = new LbbMemberTradeExample();
                if (size != null) {
                    example.setLimit(size);
                }
                if (page != null) {
                    example.setOffset((page - 1) * size.longValue());
                }
                example.createCriteria().andMemberIdEqualTo(userid)
                        .andAppIdEqualTo(appid)
                        .andCategoryEqualTo(category)
                        .andHasDeletedEqualTo(Booleans.False.name())
                        .andOrderIdNotEqualTo("xxx");
                example.setOrderByClause("create_time desc");
                List<LbbMemberTrade> list = memberTradeService.selectByExample(example);
                if (category.equals(TradeCategory.Outlay.name())) {
                    list.forEach(s -> {
                        try {
                            JSONObject jsonObject = JSON.parseObject(s.getContent());
                            jsonObject.put("money", new BigDecimal(s.getAmount()).divide(new BigDecimal(100), 2, BigDecimal.ROUND_DOWN).stripTrailingZeros().toPlainString() + "元");
                            s.setContent(JSON.toJSONString(jsonObject));
                        } catch (Exception e) {

                        }
                    });
                    List<LbbMemberTrade> list2 = memberCashWithdrawalService.selectOrder(requestHeaders);
                    list2.forEach(s -> {
                        JSONObject jsonObject = new JSONObject();
                        jsonObject.put("money", new BigDecimal(s.getAmount()).divide(new BigDecimal(100), 2, BigDecimal.ROUND_DOWN).stripTrailingZeros().toPlainString() + "元");


                        jsonObject.put("alipayname", s.getOrderId());
                        if (s.getExtra().equals(CheckStatus.SUCCESS.getIndex())) {
                            s.setStatus(TradeStatus.Success);
                        } else if (s.getExtra().equals(CheckStatus.FAIL.getIndex())) {
                            s.setStatus(TradeStatus.Invalid);
                        } else {
                            s.setStatus(TradeStatus.Empty);
                        }
                        if (!TextUtil.isEmpty(s.getPayType())) {
                            if (s.getPayType().equals(3)) {
                                s.setPayType(s.getMethod());
                            }
                        }

                        if (s.getMethod().equals(1)) {
                            jsonObject.put("alipay", s.getAppId());
                        } else {
                            jsonObject.put("alipay", s.getOrderId());
                        }

                        s.setContent(JSON.toJSONString(jsonObject));
                    });
                    list.addAll(list2);
                    list = list.stream().sorted(Comparator.comparing(LbbMemberTrade::getCreateTime).reversed()).collect(Collectors.toList());
                }
                return Callback.success("success", "已返回用户收支明细！", list);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return Callback.fail("fail", "返回用户收支明细失败！");
        } catch (Exception e) {
            e.printStackTrace();
            return Callback.fail("error", e.getMessage());
        }
    }


    /**
     * 申请提现
     *
     * @param request
     * @param response
     * @param session
     * @param type     1支付宝2微信
     * @return
     * @author weizx
     * @date 2018年7月25日 下午8:33:51
     */
    @Sessionid
    @Require
    @RequestMapping(value = "/member/wallet/apply", method = {RequestMethod.POST})
    public JsonData apply(@RequestParam(value = "content") String content,
                          @RequestParam(value = "amount") Integer amount, HttpServletRequest request, HttpServletResponse response,
                          HttpSession session, Integer type) {

        return Callback.fail("200", "当前版本过低~请升级到最新版本在提现哦!");
    }

    /**
     * 用户消息
     *
     * @param request
     * @param response
     * @param session
     * @return
     * @author weizx
     * @date 2018年7月25日 下午9:23:46
     */
    @Sessionid
    @Require
    @RequestMapping(value = "/member/notice", method = {RequestMethod.GET, RequestMethod.POST})
    public JsonData notice(@RequestParam(value = "page", required = false) Integer page,
                           @RequestParam(value = "size", required = false) Integer size, HttpServletRequest request,
                           HttpServletResponse response, HttpSession session) {
        RequestHeaders requestHeaders = new RequestHeaders(request);
        try {
            // 校验应用
            String userid = requestHeaders.getUserid();
            String appid = requestHeaders.getAppid();
            try {
                LbbMember member = memberService.getMemberByMemberId(userid);
                if (member == null) {
                    return Callback.fail("empty", "用户不存在！", new ArrayList<Map<String, Object>>());
                }
                member.setNoticeCount(0);
                memberService.updateMemberById(member);
                List<Map<String, Object>> list = memberService.notices(userid, appid, page, size);
                return Callback.success("success", "已返回用户消息列表！", list);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return Callback.fail("fail", "获取用户消息列表失败！", new ArrayList<Map<String, Object>>());
        } catch (Exception e) {
            e.printStackTrace();
            return Callback.fail("error", e.getMessage());
        }
    }

    /**
     * 用户回馈
     */
    @Sessionid
    @Require
    @RequestMapping(value = "/member/feedback", method = {RequestMethod.GET, RequestMethod.POST})
    public JsonData feedback(@RequestParam(value = "content") String content,
                             @RequestParam(value = "picture") String picture, HttpServletRequest request, HttpServletResponse response,
                             HttpSession session) {
        RequestHeaders requestHeaders = new RequestHeaders(request);
        RequestUserInfo userInfo=new RequestUserInfo(request);
        try {
            // 校验应用
            String userid = requestHeaders.getUserid();
            String createTime = DateUtil.dateToString(new Date(), "yyyyMMdd");
            try {
                int count = memberFeedbackService.count(createTime, userid);
                if (count >= 3) {
                    return Callback.fail("fail", "请勿频繁反馈！");
                }
                LbbMemberFeedback mf = new LbbMemberFeedback();
                mf.setIpAddr(Util.getIpAddress(request));
                mf.setContent(content);
                mf.setPicture(picture);
                mf.setUserId(userid);
                mf.setFeedbackId(UUIDUtil.L());
                mf.setAppStore(requestHeaders.getAppStore());
                mf.setBrand(requestHeaders.getBrand());
                mf.setImei(requestHeaders.getImei());
                mf.setOs(requestHeaders.getOs());
                mf.setOsv(requestHeaders.getOsv());

                memberFeedbackService.insertSelective(mf,userInfo.getAppId());
                return Callback.success("success", "反馈成功！感谢您的支持！");
            } catch (Exception e) {
                e.printStackTrace();
            }
            return Callback.fail("fail", "反馈失败！");
        } catch (Exception e) {
            e.printStackTrace();
            return Callback.fail("error", e.getMessage());
        }
    }

    @Require
    @Sessionid
    @RequestMapping(value = "/member/feedbacks", method = {RequestMethod.GET, RequestMethod.POST})
    public JsonData feedbacks(HttpServletRequest request, HttpServletResponse response, HttpSession session) {
        RequestHeaders requestHeaders = new RequestHeaders(request);
        try {
            // 校验应用
            String userid = requestHeaders.getUserid();
            try {
                List list = new ArrayList();
                Map<String, Object> data = memberFeedbackService.hasCompleted(userid);
                List r = (List) data.get("rows");
                for (Object obj : r) {
                    Map o = (Map) obj;
                    Map<String, Object> d = new HashMap<>();
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    d.put("createTime", sdf.format(o.get("createTime")));
                    d.put("content", o.get("content"));
                    d.put("picture", o.get("picture"));
                    d.put("result", o.get("result"));
                    list.add(d);
                }
                data.put("rows", list);
                return Callback.success("success", "反馈成功！感谢您的支持！", data);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return Callback.fail("fail", "反馈失败！");
        } catch (Exception e) {
            e.printStackTrace();
            return Callback.fail("error", e.getMessage());
        }
    }


    @RequestMapping(value = {"/member/name"}, method = {RequestMethod.POST})
    public JsonData mz(@RequestParam(value = "name") String name, HttpServletRequest request,
                       HttpServletResponse response, String wxName) {
        RequestHeaders requestHeaders = new RequestHeaders(request);
        try {
            // 校验应用
            String appid = requestHeaders.getAppid();
            String userid = requestHeaders.getUserid();
            try {
                Map<String, Object> params = new HashMap<String, Object>(1);
                params.put("member_id", userid);
                params.put("app_id", appid);
                LbbMember member = memberService.getMemberByMemberId(userid);
                if (member == null) {
                    return Callback.fail("invalid", "账号不存在！");
                } else {
                    member.setNickname(name);
                    if (TextUtil.isEmpty(wxName)) {
                        wxName = null;
                    }
                    if (!member.getWeixinName().equals(name)) {
                        member.setWxIcard("");
                    }
                    member.setWeixinName(wxName);
                    memberService.updateMemberById(member);
                    redisClient.del("member:" + member.getMemberId());
                    return Callback.success("success", "设置成功!");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            return Callback.fail("fail", "设置失败，请稍后再试！");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Callback.success("success", "恭喜!", "");
    }

    @RequestMapping(value = {"/member/avatar"}, method = {RequestMethod.POST})
    public JsonData tx(@RequestParam(value = "avatar") String avatar, HttpServletRequest request,
                       HttpServletResponse response) {
        RequestHeaders requestHeaders = new RequestHeaders(request);
        try {
            // 校验应用
            String appid = requestHeaders.getAppid();
            String userid = requestHeaders.getUserid();
            try {
                Map<String, Object> params = new HashMap<String, Object>(1);
                params.put("member_id", userid);
                params.put("app_id", appid);
                LbbMember member = memberService.getMemberByMemberId(userid);
                if (member == null) {
                    return Callback.fail("invalid", "账号不存在！");
                } else {
                    member.setAvatar(avatar);
                    memberService.updateMemberById(member);
                    redisClient.del("member:" + member.getMemberId());
                    return Callback.success("success", "设置成功!");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            return Callback.fail("fail", "设置失败，请稍后再试！");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Callback.success("success", "恭喜！", "");
    }

    @RequestMapping(value = {"/member/gender"}, method = {RequestMethod.POST})
    public JsonData xb(@RequestParam(value = "gender") String gender, HttpServletRequest request,
                       HttpServletResponse response) {
        RequestHeaders requestHeaders = new RequestHeaders(request);
        try {
            // 校验应用
            String appid = requestHeaders.getAppid();
            String userid = requestHeaders.getUserid();
            try {
                Map<String, Object> params = new HashMap<String, Object>(1);
                params.put("member_id", userid);
                params.put("app_id", appid);
                LbbMember member = memberService.getMemberByMemberId(userid);
                if (member == null) {
                    return Callback.fail("invalid", "账号不存在！");
                } else {
                    member.setGender(gender);
                    memberService.updateMemberById(member);
                    return Callback.success("success", "设置成功!");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            return Callback.fail("fail", "设置失败，请稍后再试！");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Callback.success("success", "恭喜！", "");
    }

    @RequestMapping(value = {"/member/birthday"}, method = {RequestMethod.POST})
    public JsonData sr(@RequestParam(value = "birthday") String birthday, HttpServletRequest request,
                       HttpServletResponse response) {
        RequestHeaders requestHeaders = new RequestHeaders(request);
        try {
            // 校验应用
            String appid = requestHeaders.getAppid();
            String userid = requestHeaders.getUserid();
            try {
                Map<String, Object> params = new HashMap<String, Object>(1);
                params.put("member_id", userid);
                params.put("app_id", appid);
                LbbMember member = memberService.getMemberByMemberId(userid);
                if (member == null) {
                    return Callback.fail("invalid", "账号不存在！");
                } else {
                    member.setBirthday(birthday);
                    memberService.updateMemberById(member);
                    redisClient.del("member:" + member.getMemberId());
                    return Callback.success("success", "设置成功!");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            return Callback.fail("fail", "设置失败，请稍后再试！");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Callback.success("success", "恭喜！", "");
    }


    /**
     * 用户奖励列表
     *
     * @param request
     * @return
     */

    @ResponseBody
    @PostMapping("/member/newtask")
    public JsonData newtask(HttpServletRequest request) {
        RequestHeaders requestHeaders = new RequestHeaders(request);
        Map<String, Object> map = new HashMap<>(1);
        String memberId = requestHeaders.getUserid();
        String brand = requestHeaders.getAppStore();
        //新用户看的
        if (TextUtil.isEmpty(memberId)) {
            return Callback.success("success", "查询成功", newTaskService.newMemberInfo());
        }
        //设备号不存在白名单
        if (!registerWhiteImeiService.getImei(requestHeaders.getImei())) {
            LbbMember lbbMember = memberService.selectByImei(requestHeaders.getImei());
            Result<String> result = memberService.getlbbMember(lbbMember, memberId, requestHeaders.getImei());
            if (result.getStatus() != null) {
                return Callback.fail(result.getStatus(), result.getMessage());
            }

        }

        LbbMember member = memberService.selectMemberById(memberId);
        if (member == null) {
            return Callback.success("success", "查询成功", newTaskService.newMemberInfo());
        }
        if (member.getCreateTime().before(MEMBER_DATE)) {
            return Callback.fail("success", "查询成功", map);
        }
        //判断用户处于那个阶段
        Integer status = 1;
//        if (status > 1) {
//            if (newTaskService.checkTime(status - 1, memberId)) {
//                status = status - 1;
//            }
//        }
        //阶段奖励数据
        TaskRewards memberRewards = newTaskService.selectById(status);
        //获取该阶段全部任务
        List<TaskRewards> rewards = newTaskService.getRewardListByParentId(status, brand);
        Integer all = walletService.cash(requestHeaders.getUserid(), requestHeaders.getAppid(), TradeCategory.Income.name(), RewardType.Cash.name(), null, null);
        rewards = appLookCategoryService.reviewRewards(rewards, requestHeaders, all);
        //下一阶段任务展示
        List<TaskRewards> no_rewards = newTaskService.getRewardListByParentId(status + 1, brand);
        //-2代表不能点击
        no_rewards.forEach(vo -> vo.setSort(-2));
        //判断是否完成了
        rewards.forEach(vo -> {
            TaskRewardsRecord record = newTaskService.getRecordByMemberIdAndRewardsId(memberId, vo.getId());
            if (record == null) {
                //没完成
                vo.setSort(-1);
            } else {
                //完成了0未领取奖励1已领取
                vo.setSort(record.getStatus());
                //领取奖励的id
                vo.setHasDeleted(record.getId());
            }
        });
        TaskRewardsRecord record = newTaskService.getRecordByMemberIdAndRewardsId(memberId, memberRewards.getId());
        if (record == null) {
            memberRewards.setSort(-1);
        } else {
            memberRewards.setSort(record.getStatus());
            //领取奖励的id
            memberRewards.setHasDeleted(record.getId());
        }
        map.put("memberRewards", memberRewards);
        map.put("rewards", rewards);
        map.put("no_rewards", no_rewards);
        return Callback.success("success", "查询成功", map);
    }


    /**
     * 新手任务下一个
     *
     * @param request
     * @return
     */

    @ResponseBody
    @Require
    @PostMapping("/member/newtask/wait")
    public JsonData newtaskwait(HttpServletRequest request) {
        RequestHeaders requestHeaders = new RequestHeaders(request);
        Map<String, Object> map = new HashMap<>(1);
        String memberId = requestHeaders.getUserid();
        String brand = requestHeaders.getAppStore();
        //新用户看的
        if (TextUtil.isEmpty(memberId)) {
            return Callback.success("success", "查询成功", newTaskService.newMemberInfo());
        }
        LbbMember member = memberService.selectMemberById(memberId);
        if (member == null) {
            return Callback.success("success", "查询成功", newTaskService.newMemberInfo());
        }
        if (member.getCreateTime().before(MEMBER_DATE)) {
            return Callback.fail("success", "查询成功", map);
        }
        TaskRewardsRecord record = newTaskService.getRecordByMemberIdAndRewardsId(memberId, 1);
        if (record != null) {
            return Callback.fail("success", "查询成功");
        }
        //获取该阶段全部任务
        List<TaskRewards> rewards = newTaskService.getRewardListByParentId(1, brand);
        Integer all = walletService.cash(requestHeaders.getUserid(), requestHeaders.getAppid(), TradeCategory.Income.name(), RewardType.Cash.name(), null, null);
        rewards = appLookCategoryService.reviewRewards(rewards, requestHeaders, all);
        //判断是否完成了
        for (TaskRewards vo : rewards) {
            TaskRewardsRecord k = newTaskService.getRecordByMemberIdAndRewardsId(memberId, vo.getId());
            if (k == null) {
                return Callback.success("success", "查询成功", vo);
            }
        }
        return Callback.fail("success", "查询成功");
    }

    /**
     * 领奖励
     *
     * @param request
     * @param id
     * @return
     */
    @Sessionid
    @ResponseBody
    @Require
    @PostMapping("/member/newtask/pull")
    @MemberLock
    public JsonData pull(HttpServletRequest request, Integer id) {
        RequestHeaders requestHeaders = new RequestHeaders(request);
        //提取头部数据
        RequestHeaders requsetHeader = RequestUtil.getHeader(request);
        String memberId = requestHeaders.getUserid();
        try {
            TaskRewardsRecord record = newTaskService.getRecordByMemberIdAndRecordId(memberId, id);
            if (record == null) {
                return Callback.fail("success", "你还未完成任务", null);
            } else {
                if (record.getStatus() == 0) {
                    newTaskService.pullRecord(record, requsetHeader);
                    return Callback.success("success", "领取成功", null);
                } else {
                    return Callback.fail("fail", "你已领过该奖励", null);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            return Callback.fail("fail", "领取失败", null);
        }

    }

    /**
     * 领取阶段性红包
     *
     * @param request
     * @param id
     * @return
     */
    @Sessionid
    @Require
    @ResponseBody
    @PostMapping("/member/newtask/phase")
    @MemberLock
    public JsonData phase(HttpServletRequest request, Integer id) {
        RequestHeaders requestHeaders = new RequestHeaders(request);
        RequestHeaders requsetHeader = RequestUtil.getHeader(request);
        String memberId = requestHeaders.getUserid();
        String brand = requestHeaders.getAppStore();
        try {
            int i = newTaskService.phase(requsetHeader, memberId, id, brand);
            if (i > 0) {
                return Callback.success("success", "领取成功", null);
            } else {
                if (i < 0) {
                    return Callback.fail("fail", "奖励已领取", null);
                }
                return Callback.fail("fail", "奖励未领取或任务未完成", null);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return Callback.fail("fail", "网络异常", null);
        }

    }

    /**
     * 基础奖励
     * 开权限 开门红包等
     *
     * @param request
     * @return
     */
    @Require
    @Sessionid
    @ResponseBody
    @PostMapping("/member/newtask/base")
    @MemberLock
    public JsonData base(HttpServletRequest request, Integer id) {
        RequestHeaders requestHeaders = new RequestHeaders(request);
        String memberId = requestHeaders.getUserid();
        try {
            TaskRewards rewards = newTaskService.selectById(id);
            if (rewards == null) {
                return Callback.fail("success", "任务不存在", null);
            }
            if (!rewards.getParentId().equals(1)) {
                return Callback.fail("success", "任务不存在", null);
            }
            if (rewards.getHasDeleted().equals(1)) {
                return Callback.fail("success", "任务不存在", null);
            }
            int i = newTaskService.base(rewards, memberId);
            if (i > 0) {
                return Callback.success("success", "任务完成", null);
            } else {
                return Callback.fail("fail", "任务已完成", null);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return Callback.fail("200", "请求过于频繁", null);
        }
    }
    /**
     * 基础奖励
     * 开权限 开门红包等
     *
     * @param request
     * @return
     */
    @Require
    @Sessionid
    @ResponseBody
    @PostMapping("/member/newtask/base/category")
    @MemberLock
    public JsonData basecategory(HttpServletRequest request, Integer category) {
        if(category>=700||category<=600){
            return Callback.fail("success", "任务不存在", null);
        }
        RequestHeaders requestHeaders = new RequestHeaders(request);
        String memberId = requestHeaders.getUserid();
        try {
            TaskRewards rewards = newTaskService.selectByCategory(category);
            if (rewards == null) {
                return Callback.fail("success", "任务不存在", null);
            }
            if (!rewards.getParentId().equals(1)) {
                return Callback.fail("success", "任务不存在", null);
            }
            if (rewards.getHasDeleted().equals(1)) {
                return Callback.fail("success", "任务不存在", null);
            }
            int i = newTaskService.base(rewards, memberId);
            if (i > 0) {
                return Callback.success("success", "任务完成", null);
            } else {
                return Callback.fail("fail", "任务已完成", null);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return Callback.fail("200", "请求过于频繁", null);
        }
    }
    /**
     * 提现奖励接口
     *
     * @param request
     * @return
     */
    @Require
    @Sessionid
    @ResponseBody
    @PostMapping("/member/newtask/list")
    public JsonData recordList(HttpServletRequest request, Integer id) {
//        RequestHeaders requestHeaders = new RequestHeaders(request);
//        String memberId = requestHeaders.getUserid();
//        LbbMember member = memberService.selectMemberById(memberId);
//
//        if (member.getCreateTime().before(MEMBER_DATE) && !"cash".equals(member.getPersonId())) {
//            //老用户一次都没提现过的才能做这个任务
//
//            return Callback.fail("success", "获取成功", null);
//
//        }
//        List<LbbDict> rewardsRecords = newTaskService.selectRecordListByMemberId(memberId);
        return Callback.success("success", "获取成功", null);

    }

    /**
     * 释放会员全部任务
     *
     * @param request
     * @return
     */
    @Require
    @Sessionid
    @ResponseBody
    @PostMapping("/member/task/clean")
    public JsonData clean(HttpServletRequest request) {
        RequestHeaders requestHeaders = new RequestHeaders(request);
        String memberId = requestHeaders.getUserid();
        List<LbbMemberRecord> records = memberRecordService.selectMemberRecordStatus(memberId, TaskStatus.WaitSumbit.name());
        memberRecordService.cleanByMemberId(memberId, records);
        return Callback.success("success", "释放成功", null);
    }

    /**
     * 获取用户信息
     *
     * @param request
     * @return
     */
    @Require
    @Sessionid
    @ResponseBody
    @PostMapping("/member/userinfo")
    public JsonData userinfo(HttpServletRequest request) {
        RequestHeaders requestHeaders = new RequestHeaders(request);
        String memberId = requestHeaders.getUserid();
        LbbMember member = memberService.selectMemberById(memberId);
        member.setPassword("");
        member.setWxOpenid("");
        return Callback.success("success", "查询成功", member);
    }

    /**
     * 注销用户
     *
     * @param request
     * @return
     */
    @Require
    @Sessionid
    @ResponseBody
    @PostMapping("/member/del")
    public JsonData deluserinfo(HttpServletRequest request) {
/*        String memberId = request.getHeader("userid");
        LbbMember member = memberService.selectMemberById(memberId);
        memberService.delMember(member);*/
        return Callback.success("success", "注销成功");
    }

    /**
     * 清除用户的缓存
     *
     * @param request
     * @return
     */


    @GetMapping("/member/walletClean")
    public JsonData cleanwall(HttpServletRequest request, String phone, String pa) {
        if ("xmlb8888".equals(pa)) {
            String memberId = memberService.selectByPhone(phone).getMemberId();
            memberTradeService.walletClean(memberId);
        }
        return Callback.success("success", "成功");
    }

    /**
     * 清除用户的每日发送限制
     *
     * @param request
     * @return
     */


    @GetMapping("/member/clean/phone")
    public JsonData cleanphone(HttpServletRequest request, String phone, String pa) {
        if ("xmlb8888".equals(pa)) {
            validCodeUtil.cleanPhone(phone);
        }
        return Callback.success("success", "成功");
    }

    /**
     * 补偿用户的完成新手任务截图任务
     *
     * @param request
     * @return
     */


    @GetMapping("/member/bull/phone")
    public JsonData bull(HttpServletRequest request, String phone, String pa) {
        if ("xmlb8888".equals(pa)) {
            newTaskService.addRecord(9999, memberService.selectByPhone(phone).getMemberId());
        }
        return Callback.success("success", "成功");
    }

    @GetMapping("/member/bull/sfz")
    public JsonData sfz(HttpServletRequest request, String phone, String pa) {
        if ("xmlb8888".equals(pa)) {
            redisClient.hdel(ID_CARD_COUNT, phone);
        }
        return Callback.success("success", "成功");
    }

    @Require
    @Sessionid
    @PostMapping("/member/token/add")
    public JsonData addtoken(HttpServletRequest request, String token) {
        RequestHeaders requestHeaders = new RequestHeaders(request);
        NmgToken nmgToken = new NmgToken();
        String memberId = requestHeaders.getUserid();
        nmgToken.setId(memberId);
        nmgToken.setToken(token);
        quBaoTokenMongodb.save(nmgToken);
        return Callback.success("success", "插入成功");
    }

    @Require
    @Sessionid
    @PostMapping("/member/token/get")
    public JsonData gettoken(HttpServletRequest request) {
        RequestHeaders requestHeaders = new RequestHeaders(request);
        String memberId = requestHeaders.getUserid();
        Optional<NmgToken> nmgToken = quBaoTokenMongodb.findById(memberId);
        return nmgToken.map(value ->
                Callback.success("success", "查询成功", value.getToken())).orElseGet(() ->
                Callback.fail("success", "查询失败"));
    }

    @Require
    @Sessionid
    @PostMapping("/member/icard")
    @MemberLock
    public JsonData icard(HttpServletRequest request,
                          String icard, Integer type, String name,
                          @RequestHeader("userid") String memberId) {
        if (TextUtil.isEmpty(icard, type)) {
            return Callback.fail("success", "参数非法");
        }
        if (!NumberUtils.isNumber(icard
                .replace("x", "")
                .replace("X", ""))) {
            return Callback.fail("success", "身份证格式错误");
        }
        if (icard.length() != 18) {
            return Callback.fail("success", "身份证格式错误");
        }

        LbbMember member = memberService.getMemberByMemberId(memberId);
        if (memberService.checkByICard(icard, type, 0)) {
            return Callback.fail("success", "已有账号绑定身份证,请联系客服");
        }
        //检查用户身份表内用户信息是否存在
        MemberIdentityInfo memberIdentityInfo = memberIdentityInfoService.selectOneByCard(icard,name);
        if (memberIdentityInfo != null) {
            if (type == 1) {
                member.setZfbIcard(memberIdentityInfo.getIcard());
                member.setAlipayName(memberIdentityInfo.getRealName());
            } else {
                member.setWxIcard(memberIdentityInfo.getIcard());
                member.setWeixinName(memberIdentityInfo.getRealName());
            }
            member.setBirthday(memberIdentityInfo.getBirthday());
            member.setAddrCode(memberIdentityInfo.getIcardCode());
            member.setGender(memberIdentityInfo.getSex());

        } else {
            IdCardStatus record = validCodeUtil.checkIdCard(name, icard, member.getPhone());
            if (!record.isStatus()) {
                return Callback.fail("success", record.getMsg(), record.getMsg());
            } else {
                if (type == 1) {
                    member.setZfbIcard(icard);
                    member.setAlipayName(name);
                } else {
                    member.setWxIcard(icard);
                    member.setWeixinName(name);
                }
                String birthDay = icard.substring(6, 14);
                String code = icard.substring(0, 6);
                member.setBirthday(birthDay);
                member.setAddrCode(code);
                String ex = icard.substring(16, 17);
                if (NumberUtils.createInteger(ex) % 2 == 0) {
                    member.setGender(Gender.Female.name());
                } else {
                    member.setGender(Gender.Male.name());
                }
            }
            //验证不存在,用户身份信息写入表内
            memberIdentityInfoService.insertInfo(icard, name);
        }


        memberService.updateMemberById(member);
        return Callback.success("success", "检测成功");
    }


    /**
     * 申请提现
     *
     * @param request
     * @param response
     * @param type     1支付宝2微信
     * @return
     * @author weizx
     * @date 2018年7月25日 下午8:33:51
     */
    @Sessionid
    @Require
    @RequestMapping(value = {"/member/wallet/v2/apply", "/member/wallet/v1/apply"}, method = {RequestMethod.POST})
    @MemberLock
    public JsonData applyv2(Integer id, HttpServletRequest request, HttpServletResponse response,
                            Integer type) {

        if (TextUtil.isEmpty(id, type)) {
            return Callback.fail("200", "非法参数");
        }
        if (id <= 0 || type > 2 || type <= 0) {
            return Callback.fail("200", "非法参数");
        }
        // 校验应用
        RequestHeaders requestHeaders = new RequestHeaders(request);
        String userid = requestHeaders.getUserid();
        String appid = requestHeaders.getAppid();
        LbbMember member = memberService.getMemberByMemberId(userid);
        try {
            //验证用户的身份证
            //校验微信是否绑定
            String iCard = "";
            if (type == 2) {
                iCard = member.getWxIcard();
            } else {
                iCard = member.getZfbIcard();
            }
            if (memberService.checkByICard(iCard, type, 1)) {
                return Callback.fail("success", "已有账号绑定身份证,请联系客服");
            }
            if (TextUtil.isEmpty(iCard)) {
                return Callback.fail("202", "请完善身份证信息");
            }
            if (!NumberUtils.isNumber(iCard
                    .replace("x", "")
                    .replace("X", ""))) {
                return Callback.fail("203", "请完善身份证信息");
            }
            if (iCard.length() != 18) {
                return Callback.fail("204", "请完善身份证信息");
            }

            Cash cash = cashMapper.selectByPrimaryKey(id);
            if (cash == null) {
                return Callback.fail("201", "非法参数", null);
            }
            if (TextUtil.isEmpty(member.getWeixinName(), member.getWxIcard()) && type == 2) {
                return Callback.fail("200", "申请失败,用户未实名,请让用户在个人资料填上真实姓名");
            }
            if (member.getWxStatus().equals(0) && type == 2) {
                return Callback.fail("200", "转账失败,用户微信未绑定!!");
            }
            if (TextUtil.isEmpty(member.getAlipay(), member.getAlipayName(), member.getZfbIcard()) && type == 1) {
                return Callback.fail("200", "提现失败！填完支付宝账号记得点击右边【确定】按钮哦");
            }
            int amount = cash.getCashMoney().multiply(new BigDecimal(100)).intValue();
            if (!walletService.allow(userid, appid) || memberCashWithdrawalService.allow(userid)) {
                return Callback.fail("waitting", "您还有一笔提现申请未处理，请等待!");
            }
            //long money = memberWalletService.getMoneyByMemberId(userid);
            Integer amounts = walletService.getAllows(userid, appid);
            if (amount > amounts) {

                return Callback.fail("invalid", "您的可提现金额不足!");
            }
            memberCashWithdrawalService.creatWishCash(member, type, amount, requestHeaders);
            uMengPushComponent.sendTask("咸鱼提现", "亲,您有新提现问题等待处理哟");

            memberNoticeService.addNoticeAndPush("提现申请已提交", "您的提现申请已提交成功，请耐心等待", userid, requestHeaders);
            return Callback.success("success", "提现申请成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return Callback.fail("fail", "提现申请失败");
        }
    }

    @PostMapping("/member/history/list")
    public JsonData histtorylist(HttpServletRequest request) {
        RequestHeaders requestHeaders = new RequestHeaders(request);
        List<MemberCashWithdrawal> list = memberCashWithdrawalService.selectList(requestHeaders.getUserid());
        return Callback.success("success", "查询成功", list);
    }


    @PostMapping("/clean/point/redis")
    public JsonData redis(HttpServletRequest request, String memberId, int money, String pass) {
        if (pass.equals("8888")) {
            rankingService.membersubScore(memberId, money);
        }
        return Callback.success("success", "查询成功", null);
    }


    public static void main(String[] args) {
        Date date = new Date();
        System.out.println(date.before(MEMBER_DATE));
    }


    @PostMapping("/saddasda")
    public JsonData reles(HttpServletRequest request, String pass) {
        if (!pass.equals("9999")) {
            return Callback.success("success", "查询成功", null);
        }
        List<String> memberId = memberService.selectAllMember();
        AtomicInteger atomicInteger = new AtomicInteger(0);
        memberId.parallelStream().forEach(s -> {
            memberWalletService.deleteById(s);
            memberWalletService.initData(s);
            System.out.println(atomicInteger.addAndGet(1));
        });
        return Callback.success("success", "查询成功", null);
    }
}